package conn;

import java.net.UnknownHostException;
import java.sql.Connection;

import org.apache.log4j.Logger;

import common.Constant;

public class DBUtil {
	private static Logger log;
	public static ConnectionPool rp_pool;

	public static void Init() throws UnknownHostException {
		log = Logger.getLogger(DBUtil.class);
		rp_pool = new ConnectionPool("rp_conn", Constant.rpConnString_test, 4);
		//		note_pool = new ConnectionPool("note_conn",
		//				Constant.NoteConnString_test, 3);
		// hostname = java.net.InetAddress.getLocalHost().getHostName();
		// LockSql =
		// "UPDATE v2_center_cron_lock SET hostname='"+hostname+"',time=now() WHERE id=1 and ((date_add(time,interval 5 second)<=now() and hostname='"+hostname+"') or (date_add(time,interval 50 second)<=now() and hostname!='"+hostname+"'))";

	}

	public static void CloseConn(Connection conn) {
		if (conn != null) {
			try {
				conn.close();
			} catch (Exception ex) {
				log.error("close conn error", ex);
			}
		}
	}

}
